package com.neusoft.chenhanhua.ChineseChess;

public class Pao {
	public boolean pao(int x1,int y1,int x2,int y2, int i,int [] xs,int [] ys) {
		//直行
		if (x1==x2 && y1 != y2 ) {
			for (int j = 0; j < xs.length; j++) {
				//xs[j]==x1找出同在一列的棋子，y1<y2判断是向下移的，y1<ys[j]&&y2>=ys[j]，判断中间是否有棋
				if ((xs[j]==x1&&y1<y2&&y1<ys[j]&&y2>=ys[j]) || (xs[j]==x1&&y1>y2&&y1>ys[j]&&ys[j]>=y2) ) {
				
					return false;
				}
			}
			return true;
		}
		if ( x1!=x2 && y1 == y2) {
			for (int j = 0; j < ys.length; j++) {
				//ys[j]==y1找出在同行的棋子,x2>x1判断是右移，xs[j]>x1&&x2>=xs[j]，判断中间是否有棋子
				if (ys[j]==y1&&x2>x1&&xs[j]>x1&&x2>=xs[j] || (ys[j]==y1&&x1>x2&&x1>xs[j]&&xs[j]>=x2) ) {
					return false;
				}
			}
			
			return true;
		}
		return false;
	}

}
